//
//  AOTMViewController.m
//  Mecca
//
//  Created by Nico Villanueva iOS Dev on 8/9/14.
//  Copyright (c) 2014 TapDash Heuristics. All rights reserved.
//

#import "AOTMViewController.h"

#import "HomeData.h"

#import "ParserClass.h"

#import "UIManager.h"

#import "RotationTabViewController.h"

#import "JsonClass.h"

#import "PostClass.h"

@interface AOTMViewController (){
    NSDictionary *json;
    
}

@end

@implementation AOTMViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    
    HomeData *homeData = [[ParserClass sharedItems] homeDataInterface][0];
    
    self.lblArtistName.text = [homeData artistName];
    self.lblScreenName.text = [homeData artistScreenName];
    self.lblGenre.text = [homeData artistGenre];
    self.tfDescription.text = [homeData artistDesc];
    
    
    
    
    self.tfDescription.textColor = [UIColor whiteColor];
    self.tfDescription.font = [UIFont systemFontOfSize:10.0];
    
    
    NSLog(@"Desc = %@", [homeData artistDesc]);
    
    [self setImageStringAOTM:[homeData artistPicture]];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)btnBack:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)btnAlbum:(id)sender {
    HomeData *artist = [[[ParserClass sharedItems] homeDataInterface] objectAtIndex:0];

    [[ParserClass sharedItems] getArtistID:[artist artistID]];
    
    [[ParserClass sharedItems] getArtistName:[artist artistName]];
    
    [[ParserClass sharedItems] getArtistImg:[artist artistPicture]];
    
    [self presentViewController:[[UIManager sharedItems] artistTabBars] animated:YES completion:nil];
    
}

-(void)setImageStringAOTM:(NSString *)strImage{
    
    NSString *strImg = [NSString stringWithFormat:@"http://192.185.93.102/~boomeran/backend-panel/%@",strImage];
    
    [NSThread detachNewThreadSelector:@selector(showImageAOTM:) toTarget:self withObject:strImg];
}

-(void)showImageAOTM:(NSString*)imageShow{
    
    @autoreleasepool {
        NSData *imageList = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageShow]];
        [self.imgCover setAlpha:0];
        [UIView animateWithDuration:1 animations:^{
            
            UIImage *image = [UIImage imageWithData:imageList];
            
            self.imgCover.image = image;
            [self.imgCover setAlpha:1];
            
        } completion:^(BOOL finished) {
        }];
    }
}

@end
